<template>
  <div class="more">
    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
      <!-- 批次线 -->
      <el-tab-pane label="批次线" name="first">
        <div class="select-box">
          <!-- 省份 -->
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            @change="provinceChange"
            v-model="provinceVal1"
            placeholder=" "
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in provinceValList1"
              :key="item.id"
              :label="item.provinceName"
              :value="item.id"
            />
          </el-select>
        </div>
        <div>
          <div
            class="table-row el-col el-col-24 f14"
            v-for="item in piciData"
            :key="item.year"
          >
            <div class="table-fixed">
              <div class="pcl-title">{{ item.year || '-' }}年批次线</div>
              <table class="pcl-table" border="1">
                <thead>
                  <th width="300">批次/段</th>
                  <th width="300">科目</th>
                  <th width="300">控制分数线</th>
                  <th
                    class="df"
                    style="
                      height: 59px;
                      justify-content: center;
                      border: 1px solid transparent;
                    "
                  >
                    <div>压线分区间</div>
                    <el-tooltip placement="top">
                      <template #content>
                        【压线分区间】因省控线通常按该批次计划总<br />数的120%划线，因此会导致该批次近20%考生<br />存在滑档或退档风险。在此我们通过逆向计算<br />得到压线分区间，建议在此分数区间的考生选择<br />多批次填报，以降低退/滑档风险。
                      </template>
                      <QuestionFilled style="width: 16px" />
                    </el-tooltip>
                  </th>
                </thead>
              </table>
            </div>
            <table
              border-spacing="0"
              cellspacing="1"
              v-for="chilItem in item.batches"
              :key="chilItem.id"
            >
              <tbody>
                <tr>
                  <td
                    width="300"
                    align="center"
                    class="batch"
                    style="font-weight: bold"
                  >
                    {{ chilItem.batch || '-' }}
                  </td>
                  <td width="300" align="center">
                    {{ chilItem.course || '-' }}
                  </td>
                  <td width="300" align="center">
                    {{ chilItem.score || '-' }}
                  </td>
                  <td align="center">{{ chilItem.pressureRange || '-' }}</td>
                </tr>
                <tr class="remark-row" v-if="chilItem.eligibleMajorScore">
                  <td colspan="5">
                    <span class="text-666 f12" style="margin-left: 20px"
                      >专业分：{{ chilItem.eligibleMajorScore || '-' }}</span
                    >
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>

        <!-- 提示 -->
        <div class="uzy-tzy-tip-instruction">
          <div class="el-row">
            <span class="titleBox">
              <div class="df">
                <el-icon class="iconBox">
                  <WarningFilled />
                </el-icon>
                <h6>重要提示：</h6>
              </div>
              <div
                class="dataDescription"
                v-html="pclDescription"
                style="white-space: pre-wrap"
              ></div>
            </span>
          </div>
        </div>
      </el-tab-pane>

      <!-- 一分一段 -->
      <el-tab-pane label="一分一段" name="second">
        <div class="select-box" style="align-items: center">
          <!-- 省份 -->
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            @change="provinceChange2(provinceVal2, '一分一段')"
            v-model="provinceVal2"
            placeholder=" "
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in provinceValList2"
              :key="item.provinceCode"
              :label="item.provinceName"
              :value="item.provinceCode"
            />
          </el-select>

          <!-- 年份 -->
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            v-model="year"
            placeholder=" "
            @change="yearChange"
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in yearList"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>

          <!-- 专业 -->
          <el-select
            no-data-text="暂无数据"
            @change="subjectChange"
            v-model="profession"
            placeholder=" "
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in professionList"
              :key="item"
              :label="item.course"
              :value="item.course"
            />
          </el-select>

          <el-select
            no-data-text="暂无数据"
            @change="levelChange"
            v-model="levelVal"
            placeholder=" "
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in levelOptionsList"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>

          <!-- 搜索 -->
          <div class="search df">
            <el-input
              v-model="score"
              style="width: 120px"
              placeholder="请输入分数"
              onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))"
              clearable
            />
            <el-button type="primary" @click="getSchoolScorelineList(score)"
              >查询</el-button
            >
          </div>

          <!-- 区间 -->
          <div class="section">
            {{ year }}年位次区间: {{ highestRank }} ~ {{ lowestRank }} 位
          </div>
          <div class="section">{{ year }}年同分人数: {{ sameCount }}人</div>
        </div>

        <div class="table1">
          <div class="title">历年等效分</div>
          <el-table
            :data="scoreTableData"
            style="width: 100%"
            v-loading="loading1"
          >
            <el-table-column label="类型/年份" prop="year">
              <template #default="scope">
                <div>
                  {{ scope.row.year == 0 ? '-' : scope.row.year }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="我的等效位" prop="eqRank">
              <template #default="scope">
                <div>
                  {{ scope.row.eqRank == 0 ? '-' : scope.row.eqRank }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="我的等效分" prop="eqScore">
              <template #default="scope">
                <div>
                  {{ scope.row.eqScore == 0 ? '-' : scope.row.eqScore }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="批次控制线" prop="score">
              <template #default="scope">
                <div>
                  {{ scope.row.score == 0 ? '-' : scope.row.score }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="线差">
              <template #default="scope">
                <div>
                  {{
                    scope.row.eqScore == 0 || scope.row.score == 0
                      ? '-'
                      : scope.row.eqScore - scope.row.score
                  }}
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <div class="table2">
          <div class="title">
            {{ provinceVal2Name }} {{ year }} {{ profession }}
            {{ levelVal }} 分段表
          </div>
          <el-table :data="tableData" style="width: 100%" v-loading="loading2">
            <el-table-column label="分数">
              <template #default="scope">
                <div>
                  {{
                    scope.row.minScore == scope.row.maxScore
                      ? scope.row.minScore
                      : scope.row.minScore + '-' + scope.row.maxScore || '-'
                  }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="位次区间">
              <template #default="scope">
                <div>
                  {{
                    scope.row.highestRank + '-' + scope.row.lowestRank || '-'
                  }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="同分人数">
              <template #default="scope">
                <div>
                  {{ scope.row.sameCount || '-' }}
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>

      <!-- 同分去向 -->
      <el-tab-pane label="同分去向" name="third">
        <div
          class="select-box"
          style="
            align-items: center;
            padding: 16px 0 11px 0;
            justify-content: space-between;
          "
        >
          <div>
            <!-- 省份 -->
            <el-select
              v-model="provinceVal2"
              no-data-text="暂无数据"
              style="width: 90px; margin: 0 10px"
              @change="provinceChange2(provinceVal2, '同分去向')"
            >
              <el-option
                v-for="item in provinceValList2"
                :key="item.provinceCode"
                :label="item.provinceName"
                :value="item.provinceCode"
              />
            </el-select>

            <!-- 专业 -->
            <el-select
              no-data-text="暂无数据"
              @change="subjectChange"
              v-model="profession"
              placeholder=" "
              style="width: 90px; margin: 0 10px"
            >
              <el-option
                v-for="item in professionList"
                :key="item"
                :label="item.course"
                :value="item.course"
              />
            </el-select>

            <el-select
              no-data-text="暂无数据"
              @change="levelChange"
              v-model="levelVal"
              placeholder=" "
              style="width: 90px; margin: 0 10px"
            >
              <el-option
                v-for="item in levelOptionsList"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
          </div>

          <!-- 搜索 -->
          <div class="search df">
            <el-input
              v-model="TFscore"
              style="width: 240px"
              placeholder="请输入分数"
              onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))"
              clearable
            />
            <el-button type="primary" @click="searchTFlists(TFscore, 'search')"
              >查询</el-button
            >
          </div>

          <!-- 同分区间 -->
          <div class="scoreBox" v-show="TFscoreShow">
            <span>等效分</span>
            <div class="el-divider"></div>
            <div
              v-for="(item, index) in scoreTableData.slice(0, 3)"
              :key="index"
              :class="['score pointer', { isChecked: selectedIndex === index }]"
              @click="
                selectScore(index, item.eqScore, scoreTableData.slice(0, 3))
              "
            >
              <span>{{ item.eqScore }}</span> ·
              <span class="text-info">{{ item.year }}</span>
            </div>
          </div>
        </div>

        <div style="width: 100%">
          <div class="table-search" v-show="TFscoreShow">
            <div class="top" style="width: 100%">
              <div class="left">
                <div
                  class="left-item"
                  :class="{ active: tableActiveItem === '院校' }"
                  @click="tableSetActiveItem('院校')"
                >
                  院校
                </div>
                <div
                  class="left-item"
                  :class="{ active: tableActiveItem === '专业' }"
                  @click="tableSetActiveItem('专业')"
                >
                  专业
                </div>
                <div
                  class="left-item"
                  :class="{ active: tableActiveItem === '地区' }"
                  @click="tableSetActiveItem('地区')"
                >
                  地区
                </div>
              </div>
              <div class="tabstag-score right">
                <span class="button" @click="updateScore(-5)">-5分</span>
                <span class="txt">{{ TFminscore }} - {{ TFmaxscore }}分</span>
                <span class="button" @click="updateScore(5)">+5分</span>
              </div>
            </div>
            <!-- <div class="down">
              <div class="table-header">
                <div class="row plan-major-title">
                  <div class="plan-major-title-item">录取人数排名</div>
                  <div class="plan-major-title-item" v-if="tableActiveItem == '院校'">院校</div>
                  <div class="plan-major-title-item" v-if="tableActiveItem == '专业'">专业</div>
                  <div class="plan-major-title-item" v-if="tableActiveItem == '地区'">地区</div>
                  <div class="plan-major-title-item" v-if="tableActiveItem != '地区'">填报指数</div>
                  <div class="plan-major-title-item" v-if="tableActiveItem == '地区'">院校数</div>
                  <div class="plan-major-title-item">录取人数</div>
                  <div class="plan-major-title-item">人数占比</div>
                </div>
              </div>
            </div> -->
          </div>

          <!-- 表格 -->
          <div
            class="el-table table-content"
            ref="contentRef"
            v-show="TFscoreShow"
          >
            <el-table :data="tableData2" :show-header="true">
              <el-table-column prop="collegeNameText" label="录取人数排名">
                <template #default="scope">
                  <p>
                    {{ scope.row.index }}
                  </p>
                </template>
              </el-table-column>

              <el-table-column
                prop="batch"
                label="院校"
                v-if="tableActiveItem == '院校'"
              >
                <template #default="scope" v-if="tableActiveItem == '院校'">
                  <p>
                    {{ scope.row.college ? scope.row.college.cnName : '-' }}
                  </p>
                  <p class="remarks">
                    {{
                      scope.row.college ? scope.row.college.natureTypeZW : ''
                    }}
                    {{
                      scope.row.college
                        ? scope.row.college.provinceName +
                          '(' +
                          scope.row.college.cityName +
                          ')'
                        : ''
                    }}
                    {{ scope.row.college ? scope.row.college.bz : '-' }}
                    {{
                      scope.row.college
                        ? scope.row.college.categories.length
                          ? scope.row.college.categories[0]
                          : ''
                        : ''
                    }}
                  </p>
                </template>
              </el-table-column>
              <el-table-column
                prop="batch"
                label="专业"
                v-if="tableActiveItem == '专业'"
              >
                <template #default="scope" v-if="tableActiveItem == '专业'">
                  <p>
                    {{ scope.row.major ? scope.row.major.name : '-' }}
                  </p>
                  <p class="remarks">
                    {{ scope.row.major ? scope.row.major.bz : '' }}
                    {{ scope.row.major ? scope.row.major.largeName : '' }}
                    {{
                      scope.row.major ? scope.row.major.learnYear + '年' : ''
                    }}
                  </p>
                </template>
              </el-table-column>
              <el-table-column
                prop="batch"
                label="地区"
                v-if="tableActiveItem == '地区'"
              >
                <template #default="scope">
                  <p>
                    {{ scope.row.provinceName }}
                  </p>
                </template>
              </el-table-column>

              <el-table-column
                prop="totalWeight"
                label="填报指数"
                v-if="tableActiveItem != '地区'"
              >
                <template #default="scope">
                  {{ scope.row.totalWeight || scope.row.totalWeight || '-' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="collegeNum"
                label="院校数"
                v-if="tableActiveItem == '地区'"
              >
                <template #default="scope">
                  {{ scope.row.collegeNum || scope.row.collegeNum || '-' }}
                </template>
              </el-table-column>
              <el-table-column prop="enterNum" label="录取人数">
                <template #default="scope">
                  {{ scope.row.enterNum || scope.row.enterNum || '-' }}
                </template>
              </el-table-column>
              <el-table-column prop="ratioStr" label="人数占比">
                <template #default="scope">
                  {{ scope.row.ratioStr || scope.row.ratioStr || '-' }}
                </template>
              </el-table-column>
            </el-table>

            <!-- 分页 -->
            <div class="right" style="margin-top: 20px">
              <el-pagination
                v-model:current-page="pageData1.pageIndex"
                v-model:page-size="pageData1.pageSize"
                :page-sizes="[10, 20, 50]"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageData1.total"
                @size-change="searchTFlists(TFminscore)"
                @current-change="searchTFlists(TFminscore)"
              />
            </div>
          </div>
        </div>
      </el-tab-pane>

      <!-- 选科查询 -->
      <el-tab-pane label="选科查询" name="four">
        <div class="select-box" style="align-items: center; padding-bottom: 0">
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            @change="xkEduLevelChange(eduLevelValue)"
            v-model="eduLevelValue"
            placeholder=" "
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in eduLevelList"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            />
          </el-select>
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            @change="xkProvinceChange(provinceVal3)"
            v-model="provinceVal3"
            placeholder=" "
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in provinceValList3"
              :key="item.provinceCode"
              :label="item.provinceName"
              :value="item.provinceCode"
            />
          </el-select>
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            v-model="year2"
            placeholder=" "
            @change="xkYearChange"
            style="width: 90px; margin: 0 10px"
          >
            <el-option
              v-for="item in yearList2"
              :key="item.year"
              :label="item.year"
              :value="item.year"
            />
          </el-select>
        </div>
        <schoolDate
          ref="schoolDateinfo"
          :storeType="1"
          :studentId="student_id * 1"
          :isSelectedSubjects="false"
        ></schoolDate>
        <div id="ToolCollegeLibraryList">
          <el-table
            :data="collegeTableData"
            style="width: 100%"
            stripe
            @expand-change="handleExpandChange"
            row-key="collegeCode"
            :header-cell-style="{
              color: '#86909c',
              fontSize: '16px',
            }"
            :expand-row-keys="expandedRowKeys"
          >
            <el-table-column prop="rank" label="排名" align="center" />
            <el-table-column prop="collegeName" label="院校名称" width="300px">
              <template #default="scope">
                <div>
                  <div style="font-weight: bold">
                    {{ scope.row.collegeName }}
                  </div>
                  <div class="f12" style="color: #bcc3cc">
                    <span
                      v-for="item in scope.row.features
                        ? JSON.parse(scope.row.features)
                        : []"
                      :key="item"
                      >{{ item }}&nbsp;</span
                    >
                    <span>
                      {{
                        scope.row.categories
                          ? JSON.parse(scope.row.categories)[0]
                          : ' '
                      }}
                      {{ scope.row.provinceName }}
                      （{{ scope.row.cityName }}）
                      {{ scope.row.eduLevelName }}
                      {{ scope.row.natureTypeName }}
                    </span>
                  </div>
                </div>
              </template>
            </el-table-column>

            <el-table-column label="最优组合" align="center" width="200px">
              <template #default="scope">
                <span>{{ scope.row.bestCombineName || '-' }}</span>
              </template>
            </el-table-column>

            <el-table-column label="物理" align="center">
              <template #default="scope">
                <span>
                  {{
                    scope.row.all_majors_bestCombine_percentage[1]
                      ? scope.row.all_majors_bestCombine_percentage[1] + '%'
                      : '-'
                  }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="化学" align="center">
              <template #default="scope">
                <span>
                  {{
                    scope.row.all_majors_bestCombine_percentage[2]
                      ? scope.row.all_majors_bestCombine_percentage[2] + '%'
                      : '-'
                  }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="生物" align="center">
              <template #default="scope">
                <span>
                  {{
                    scope.row.all_majors_bestCombine_percentage[3]
                      ? scope.row.all_majors_bestCombine_percentage[3] + '%'
                      : '-'
                  }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="历史" align="center">
              <template #default="scope">
                <span>
                  {{
                    scope.row.all_majors_bestCombine_percentage[4]
                      ? scope.row.all_majors_bestCombine_percentage[4] + '%'
                      : '-'
                  }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="地理" align="center">
              <template #default="scope">
                <span>
                  {{
                    scope.row.all_majors_bestCombine_percentage[5]
                      ? scope.row.all_majors_bestCombine_percentage[5] + '%'
                      : '-'
                  }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="思想政治" align="center">
              <template #default="scope">
                <span>
                  {{
                    scope.row.all_majors_bestCombine_percentage[6]
                      ? scope.row.all_majors_bestCombine_percentage[6] + '%'
                      : '-'
                  }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="right">
              <template #default="scope">
                <div
                  style="
                    display: flex;
                    align-items: center;
                    justify-content: center;
                  "
                >
                  <span style="color: var(--el-color-primary)">
                    {{ scope.row.allMajorNum }}个专业
                  </span>
                </div>
              </template>
            </el-table-column>

            <el-table-column type="expand">
              <template #default="props">
                <el-table :data="props.row.majorList">
                  <el-table-column label="专业" prop="professionName" />
                  <el-table-column
                    label="专业层次"
                    prop="eduLevel"
                    width="100px"
                  >
                    <template #default="scope">
                      {{ scope.row.eduLevel == 'ben' ? '本科' : '专科' }}
                    </template>
                  </el-table-column>
                  <el-table-column label="招生方向" prop="direction">
                    <template #default="scope">
                      {{ scope.row.direction || '-' }}
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="包含专业"
                    prop="professions"
                    width="100px"
                  >
                    <template #default="scope">
                      {{ scope.row.professions || '-' }}
                    </template>
                  </el-table-column>
                  <el-table-column label="科目要求" prop="firstRequired">
                    <template #default="scope">
                      {{ scope.row.firstRequired || '-' }}
                    </template>
                  </el-table-column>
                  <!-- <el-table-column
                    prop="isMatch"
                    label="匹配状态"
                    width="100"
                    :filters="[
                      { text: '匹配', value: '1' },
                      { text: '不匹配', value: '0' },
                    ]"
                  >
                    <template #default="scope">
                      {{ scope.row.isMatch == '1' ? '匹配' : '不匹配' }}
                    </template>
                  </el-table-column> -->
                  <!-- <el-table-column prop="isMatch" label="匹配状态" v-if="false">
                    <template #header>
                      <el-select
                        v-model="isMatchOptionsValue"
                        placeholder="Select"
                        size="small"
                        style="width: 110px"
                        @change="
                          handleSelectChange(props.row, isMatchOptionsValue)
                        "
                      >
                        <el-option
                          v-for="item in isMatchOptions"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                    </template>
                    <template #default="scope">
                      {{ scope.row.isMatch ? '匹配' : '不匹配' }}
                    </template>
                  </el-table-column> -->
                </el-table>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div style="margin: 10px 0 20px 0">
          <el-pagination
            v-show="total > 0"
            v-model:current-page="requestData.page"
            v-model:page-size="requestData.pageSize"
            :page-sizes="[10, 20, 30]"
            :total="total"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </el-tab-pane>

      <!-- 诊断成绩换算 -->
      <el-tab-pane el-tab-pane label="诊断成绩换算" name="five">
        <div
          class="select-box"
          style="align-items: center; justify-content: center"
        >
          <!-- 省份 -->
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            @change="diagnosisDataChangeProvernce(diagnosisProvernceSelecData)"
            v-model="diagnosisProvernceSelecData"
            placeholder=" "
            style="width: 300px; margin: 0 10px"
          >
            <el-option
              v-for="item in diagnosisData"
              :key="item.name"
              :label="item.name"
              :value="item.name"
            />
          </el-select>

          <!-- 地级市 -->
          <el-select
            :popper-options="{
              modifiers: [
                { name: 'computeStyles', options: { adaptive: false } },
              ],
            }"
            no-data-text="暂无数据"
            @change="diagnosisDataChangeCity(diagnosisCitySelectData)"
            v-model="diagnosisCitySelectData"
            placeholder=" "
            style="width: 300px; margin: 0 10px"
          >
            <el-option
              v-for="item in diagnosisCityData"
              :key="item.name"
              :label="item.name"
              :value="item.name"
            />
          </el-select>
        </div>
        <div
          class="select-box"
          style="align-items: center; justify-content: center"
        >
          <!-- 文理科 -->
          <el-select
            no-data-text="暂无数据"
            @change="diagnosisDataChangeWl(diagnosisTypeWlSelectData)"
            v-model="diagnosisTypeWlSelectData"
            placeholder=" "
            style="width: 300px; margin: 0 10px"
          >
            <el-option
              v-for="item in diagnosisTypeWl"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>
          <!-- 状态 -->
          <el-select
            no-data-text="暂无数据"
            @change="diagnosisDataChangeType(diagnosisTypeSelectData)"
            v-model="diagnosisTypeSelectData"
            placeholder=" "
            style="width: 300px; margin: 0 10px"
          >
            <el-option
              v-for="item in diagnosisType"
              :key="item.datakey"
              :label="item.name"
              :value="item.datakey"
            />
          </el-select>
        </div>
        <div
          class="select-box"
          style="align-items: center; justify-content: center"
        >
          <!-- 搜索 -->
          <div class="search df">
            <el-input
              v-model="diagnosisScore"
              style="width: 560px"
              placeholder="请输入诊断考试成绩"
              onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))"
              clearable
            />
            <el-button type="primary" @click="getTransScore(score)"
              >查询</el-button
            >
          </div>
        </div>

        <div class="content" v-if="transDataScore || transDataScoreRank">
          <h3 class="title">相当于近年高考</h3>
          <h4>{{ tt }}</h4>
          <div class="table">
            <span class="score"
              >成绩： <span class="num">{{ transDataScore }}</span></span
            >
            <span class="score"
              >全省排名：
              <span class="num">{{ transDataScoreRank }}</span></span
            >
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue';
import { ElMessage } from 'element-plus';
import schoolDate from '@/views/leader/volunteer/module/schoolDate.vue';
import {
  // searchSchool,
  selectSearchSchool,
  selectSearchSchoolMajor,
} from '@/api/appv2/appv1.js';

import { getLikeList } from '@/api/appv2/appv2';

import userSearch from '@/store/modules/searchInfoTool.js';
import {
  getBatchLineInfo,
  getScoreStageFilter,
  //  scoreStage
  getScoreStageInfo1,
  getScoreStageInfo2,
  getNoteDesc,
  getProvinceList,
  getSchools,
  getMajors,
  getAreas,
  searchFilter,
  transScore,
  getSelectProvince,
} from '@/api/appv2/appv2';

// const isMatchOptionsValue = ref('3');
// const isMatchOptions = ref([
//   {
//     value: '3',
//     label: '匹配状态',
//   },
//   {
//     value: '1',
//     label: '匹配',
//   },
//   {
//     value: '0',
//     label: '不匹配',
//   },
// ]);

const expandedRowKeys = ref([]); // 初始时没有展开任何行

// 计算单独写的表头的宽度
const contentRef = ref(null);
const contentWidth = ref(0);
const planTitleWidth = ref('');
// const isOpen = ref(true);
const userSearchVal = userSearch(); // 筛选仓库
let userSearchDate = computed(() => userSearchVal.searchArraylist);
const handleResize = () => {
  if (contentRef.value) {
    contentWidth.value = contentRef.value.offsetWidth + 'px';
  }

  // 获取当前窗口宽度
  let width = window.innerWidth;
  // 根据不同的宽度范围设置 drawerSize 的值
  if (width > 2000) {
    planTitleWidth.value = '60%';
  } else if (width > 1800) {
    planTitleWidth.value = '63%';
  } else if (width > 1600) {
    planTitleWidth.value = '73%';
  } else if (width > 1400) {
    planTitleWidth.value = '79%';
  } else if (width > 1200) {
    planTitleWidth.value = '84%';
  } else {
    planTitleWidth.value = '95%';
  }
};
watch(
  // 监听院校筛选数据改变
  () => userSearchDate.value,
  () => {
    schoolSearchDataChange();
  }
);
// const openTabel = () => {
//   isOpen.value = !isOpen.value;
// };
function schoolSearchDataChange() {
  let searchData = {
    province: [],
    categories: [],
    features: [],
    natureType: [],
    eduLevelSchool: [],
    schoolNewly: [],
    scode: [],
    mcode: [],
    zcode: [],
    ssearch: '',
    msearch: '',
    zsearch: '',
  };

  for (let item of userSearchDate.value) {
    switch (item.type) {
      case 'province':
        searchData.province.push(item.code);
        break;
      case 'type':
        searchData.categories.push(item.code);
        break;
      case 'school_feature':
        searchData.features.push(item.code);
        break;
      case 'nature':
        searchData.natureType.push(item.code);
        break;
      case 'school_type':
        searchData.eduLevelSchool.push(item.code);
        break;
      case 'schoolNewly':
        searchData.schoolNewly.push(item.code);
        break;
      case 'schoolSearch':
        searchData.scode.push(item.code);
        break;
      case 'major':
        searchData.mcode.push(item.code);
        break;
      case 'job':
        searchData.zcode.push(item.code);
        break;
      case 'ssearch':
        searchData.ssearch = item.name;
        break;
      case 'msearch':
        searchData.msearch = item.name;
        break;
      case 'zsearch':
        searchData.zsearch = item.name;
    }
  }

  let data = {
    province: searchData.province.toString(),
    categories: searchData.categories.toString(),
    features: searchData.features.toString(),
    natureType: searchData.natureType.toString(),
    eduLevelSchool: searchData.eduLevelSchool.toString(),
    schoolNewly: searchData.schoolNewly.toString(),
    scode: searchData.scode.toString(),
    mcode: searchData.mcode.toString(),
    zcode: searchData.zcode.toString(),
    ssearch: searchData.ssearch,
    msearch: searchData.msearch,
    zsearch: searchData.zsearch,
  };
  screenData.value = data;
  requestData.value.page = 1;
  fetchSearchSchool();
}
// 移除之前可能存在的同名监听器
window.removeEventListener('resize', handleResize);
// 添加 resize 事件监听器
window.addEventListener('resize', handleResize);
// 初始调用一次
handleResize();

onUnmounted(() => {
  window.removeEventListener('resize', handleResize);
});

const piciData = ref([]);
const collegeTableData = ref([]);
const allData = ref([]);
// 省份信息
const provinceVal1 = ref('');
const provinceValList1 = ref([]);
const provinceVal2 = ref('');
const provinceVal2Name = ref('');
const provinceValList2 = ref([]);
// 选科查询
const provinceVal3 = ref('');
const provinceValList3 = ref([]);

const student_id = localStorage.getItem('student_id');

const eduLevelValue = ref('本科');
const eduLevelList = ref([
  { id: 'ben', value: '本科' },
  { id: 'zhuan', value: '专科' },
]);
// 请求数据
const requestData = ref({
  batch: '',
  page: 1,
  pageSize: 10,
  fronttype: 3,
  fType: 0, // 0-全部
  hasZJ: 0, // 0-全部
  order: '', // 排序 chance-录取率 rank-院校排名 planNum-招生计划
  is_sort: false, // 是否升序，false升序，true降序
});
const screenData = ref({}); // 筛选数据
const year = ref('');
const yearList = ref([]);
// 选科查询
const year2 = ref('');
const yearList2 = ref([]);

const profession = ref('');
const professionList = ref([]);
const collegeTableLoading = ref(false);
const activeName = ref('first');
const total = ref(0);
// 分数
const score = ref('500');
// 位次区间显示
const highestRank = ref('');
const lowestRank = ref('');
const sameCount = ref('');
// 表格数据
const tableData = ref([]);
const scoreTableData = ref([]);
const yearscore = ref([]);
// 加载状态
const loading1 = ref(false);
const loading2 = ref(false);
const pclDescription = ref('');

// 同分去向 tab切换
// 表格数据
const tableData2 = ref([]);

const tableActiveItem = ref('院校');
function tableSetActiveItem(item) {
  tableActiveItem.value = item;
  console.log('进来1');

  searchTFlists();
}

const pageData1 = reactive({
  pageIndex: 1,
  pageSize: 10,
  total: 0,
});

// 诊断成绩换算数据
// 省份下拉框
const diagnosisData = ref({});
// 默认省份
const diagnosisProvernceSelecData = ref('');
// 地级市
const diagnosisCityData = ref([]);
// 默认地级市
const diagnosisCitySelectData = ref('');
// 状态
const diagnosisType = ref([]);
// 默认状态
const diagnosisTypeSelectData = ref('');
// 文理科
const diagnosisTypeWl = ref([]);
// 默认文理科
const diagnosisTypeWlSelectData = ref('');
// 搜索值
const diagnosisScore = ref('');
const searchDataKey = ref('');

// 搜索结果
const transDataScore = ref('');
const transDataScoreRank = ref('');
const tt = ref('');

// 同分去向 点击不同年份等效分
const selectedIndex = ref(0);
// 高亮效果
function selectScore(index, score, arr) {
  let item = arr[index];
  console.log(item, 'itemmmm', score);

  selectedIndex.value = index;
  // year.value = scoreTableData.value[index].year;
  year.value = item.year;
  TFminscore.value = Number(scoreTableData.value[index].eqScore);
  TFmaxscore.value = Number(TFminscore.value + 4);
  // 切换标签的时候把pageData1参数设置为1，如果前一个标签有第8页，点击的标签没有，就会请求两次接口，不知道什么原因
  pageData1.pageIndex = 1;
  console.log('进来2', score);
  const data = {
    year: year.value,
    course: profession.value,
    provinceCode: provinceVal2.value,
    score:findSegment(score,5)
  };
  getSearchTFlists(data);

  // searchTFlists(score);
}
// const handleCollegeList = () => {
//   requestData.value.page = 1;
//   fetchSearchSchool();
// };
const handleSizeChange = (val) => {
  requestData.value.pageSize = val;
  fetchSearchSchool();
};
const handleCurrentChange = (val) => {
  requestData.value.page = val;
  fetchSearchSchool();
};
const fetchSearchSchool = (page) => {
  let data = {
    ...requestData.value,
    ...screenData.value,
  };

  if (activeName.value == 'four') {
    data.year = year2.value;
    data.pid = provinceVal3.value;
  } else {
    data.year = year.value;
    data.pid = provinceVal2.value;
  }
  collegeTableLoading.value = true;

  if (page && page.limit) {
    data.page = page.page;
    data.pageSize = page.limit;
  }
  // searchSchool(data)
  selectSearchSchool(data)
    .then((res) => {
      if (res.code == 20000) {
        total.value = Number(res.data.total);
        collegeTableData.value = res.data.data;

        collegeTableLoading.value = false;
        if (localStorage.getItem('student_id')) {
          fetchLikeList();
        }
      } else {
        collegeTableLoading.value = false;
      }
    })
    .catch(() => {
      collegeTableLoading.value = false;
    });
};

const fetchLikeList = () => {
  let reqData = {
    type: 'school',
    studentId: localStorage.getItem('student_id'),
  };
  getLikeList(reqData).then((res) => {
    let likeSchoolArr = res?.data?.school?.split(',') || [];
    likeSchoolArr.forEach((v) => {
      collegeTableData.value.forEach((item) => {
        if (item.code == v) {
          item.isSelected = true;
        }
      });
    });
  });
};
// 点击加减5分
const TFminscore = ref();
const TFmaxscore = ref();
function updateScore(amount) {
  TFminscore.value += amount;
  TFmaxscore.value += amount;

  if (TFminscore.value <= 99) {
    TFminscore.value = 100;
    TFmaxscore.value = TFminscore.value + 4;
    ElMessage.warning('分数不能低于100分');
    return;
  }
  if (TFmaxscore.value >= 750) {
    TFmaxscore.value = 750;
    TFminscore.value = TFmaxscore.value - 4;
    ElMessage.warning('分数不能高于750分');
    return;
  }
  console.log('进来3', TFminscore.value);
  searchTFlists(TFminscore.value);
}
const handleExpandChange = async (row) => {
  // 判断是否打开行
  const index = expandedRowKeys.value.indexOf(row.collegeCode);
  if (index > -1) {
    expandedRowKeys.value.splice(index, 1);
  } else {
    expandedRowKeys.value.push(row.collegeCode);
  }

  // 判断是否是第一次打开行
  // 如果 majorList 为空，发起请求加载专业数据, 并设置 majorList
  if (row.collegeCode && !row.majorList) {
    const data = {
      collegeCode: row.collegeCode,
      year: year2.value,
      pid: row.provinceCode,
    };
    try {
      const res = await selectSearchSchoolMajor(data);
      collegeTableData.value.map((item) => {
        if (item.collegeCode == row.collegeCode) {
          item.majorList = res.data;
        }
      });
    } catch (err) {
      console.error('请求失败:', err);
    }
  }
};

const xkYearChange = () => {
  fetchSearchSchool();
};
const xkProvinceChange = (val) => {
  localStorage.setItem('provinceId', val); // 存储省份id
  yearList2.value =
    provinceValList3.value.filter((i) => i.provinceCode == val)[0]?.years ||
    provinceValList3.value[0]?.years;
  year2.value = yearList2.value[0]?.year;
  fetchSearchSchool();
};

// 同分去向-搜索框
const TFscore = ref(JSON.parse(localStorage.getItem('TFscore')) * 1 || 500);
// 每个间段的分数间隔
const interval = ref(5);

// 计算分数在哪个区间内
function findSegment(score, interval) {
  // 计算间段的起始值
  const start = Math.floor(score / interval) * interval;
  return start;
}

const TFscoreShow = ref(false);

// 同分去向-列表
async function searchTFlists(val) {
  console.log(val, '进来333', interval.value);

  localStorage.setItem('TFscore', JSON.stringify(TFscore.value));
  // 计算当前分数所在的间段起始值
  var currentSegmentStart = '';
  if (val) {
    currentSegmentStart = findSegment(val, interval.value);
  } else {
    currentSegmentStart = findSegment(TFscore.value, interval.value);
  }

  // 更新区间数据
  if (currentSegmentStart >= 99 && currentSegmentStart <= 751) {
    TFminscore.value = currentSegmentStart;
    TFmaxscore.value = currentSegmentStart + 4;
  } else {
    TFminscore.value = '';
    TFmaxscore.value = '';
  }
  console.log(!!TFscore.value, '0000', TFscore.value, currentSegmentStart);
  // 先取等效分
  // let number = currentSegmentStart;
  if (!!TFscore.value) {
    // 如果没有等位分的话去接口拿
    // if (type == 'search') {
    console.log(currentSegmentStart, 'TFscore.value', TFscore.value);

    await getScoreStageInfo1({
      bzType: levelVal.value,
      course: profession.value,
      pid: provinceVal2.value,
      score: TFscore.value ? TFscore.value : '',
      // score: val || '',
      year: year.value,
    }).then((res) => {
      console.log(res.data, 'res.data');

      scoreTableData.value = res.data;

      if (true) {
        console.log(scoreTableData.value, '报错123');

        // year.value = scoreTableData.value[0].year;

        const data = {
          year: year.value,
          course: profession.value,
          provinceCode: provinceVal2.value,
          score: val || currentSegmentStart,
        };

        if (!!currentSegmentStart) {
          if (scoreTableData.value.length > 0) {
            TFscoreShow.value = true;

            getSearchTFlists(data);
          } else {
            TFscoreShow.value = false;
            ElMessage.error('查询历年等效分失败!');
            return;
          }
        } else {
          TFscoreShow.value = false;
          ElMessage.warning('请输入分数!');
          return;
        }
      }
    });
    // }
    // 同分去向的加减分取值，首次加载取第一个最低值
    if (!TFminscore.value) {
      TFminscore.value = scoreTableData.value[0]
        ? Number(scoreTableData.value[0].eqScore)
        : '';
      TFmaxscore.value = scoreTableData.value[0]
        ? Number(TFminscore.value + 4)
        : '';
    }
  }
}

function getSearchTFlists(data) {
  if (tableActiveItem.value == '院校') {
    getSchools({ ...pageData1, ...data })
      .then((res) => {
        console.log(data, '年份有1错', year.value);
        tableData2.value = res.data.items;
        pageData1.total = res.data.totalNum;
        // 添加一个序号
        for (let v = 0; v < tableData2.value.length; v++) {
          tableData2.value[v].index = Number(
            (pageData1.pageIndex - 1) * 10 + v + 1
          );
          // 根据传参判断类型
          if (tableData2.value[v].college.natureType == 'public') {
            tableData2.value[v].college.natureTypeZW = '公办';
          } else if (tableData2.value[v].college.natureType == 'private') {
            tableData2.value[v].college.natureTypeZW = '民办';
          } else {
            tableData2.value[v].college.natureTypeZW = '中外/港澳';
          }

          // 判断本科专科
          if (tableData2.value[v].college.eduLevel == 'ben') {
            tableData2.value[v].college.bz = '本科';
          } else {
            tableData2.value[v].college.bz = '专科';
          }
        }
      })
      .catch(() => {
        ElMessage.error('操作失败，请重试');
      });
  } else if (tableActiveItem.value == '专业') {
    getMajors({ ...pageData1, ...data })
      .then((res) => {
        tableData2.value = res.data.items;
        pageData1.total = res.data.totalNum;
        // 添加一个序号
        for (let v = 0; v < tableData2.value.length; v++) {
          tableData2.value[v].index = Number(
            (pageData1.pageIndex - 1) * 10 + v + 1
          );

          // 判断本科专科
          if (tableData2.value[v].major.eduLevel == 'ben') {
            tableData2.value[v].major.bz = '本科';
          } else {
            tableData2.value[v].major.bz = '专科';
          }
        }
      })
      .catch(() => {
        ElMessage.error('操作失败，请重试');
      });
  } else if (tableActiveItem.value == '地区') {
    getAreas({ ...pageData1, ...data })
      .then((res) => {
        tableData2.value = res.data.items;
        pageData1.total = res.data.totalNum;
        // 添加一个序号
        for (let v = 0; v < tableData2.value.length; v++) {
          tableData2.value[v].index = Number(
            (pageData1.pageIndex - 1) * 10 + v + 1
          );
        }
      })
      .catch(() => {
        ElMessage.error('操作失败，请重试');
      });
  }
}

// 批次线
function provinceChange(val) {
  localStorage.setItem('provinceId', val);
  provinceVal1.value = val;
  provinceVal2.value = val;
  getBatchLineInfoList();
}
const fetchNoteDesc = () => {
  getNoteDesc({ type: 'pclDescription', studentId: '339' }).then((res) => {
    pclDescription.value = res.data.pclDescription;
  });
};
fetchNoteDesc();
// 获取省份
function fetchProvinceList() {
  getProvinceList().then((res) => {
    if (res.code == 20000) {
      provinceValList1.value = res.data;
      if (
        Number(localStorage.getItem('provinceId')) &&
        provinceValList1.value.some(
          (obj) => obj.id == Number(localStorage.getItem('provinceId'))
        )
      ) {
        provinceVal1.value = Number(localStorage.getItem('provinceId'));
      } else {
        provinceVal1.value = res.data[0].id;
      }
      getBatchLineInfoList();
    }
  });
}
fetchProvinceList();

// 获取批次线信息
function getBatchLineInfoList() {
  loading1.value = true;
  const data = {
    pid: provinceVal1.value,
    more: 1,
    less: 0,
  };
  getBatchLineInfo(data).then((res) => {
    if (res.code == 20000) {
      piciData.value = res.data;
      loading1.value = false;
    }
  });
}

const handleClick = (tab) => {
  if (tab) {
    if (tab.props.label == '批次线') {
      getBatchLineInfoList();
    } else {
      getScoreStageFilterList();
    }
  } else {
    if (activeName.value == 'first') {
      getBatchLineInfoList();
    } else {
      getScoreStageFilterList();
    }
  }
};

// 一分一段
const levelOptionsList = ref([]);
const levelVal = ref('');
const getScoreStageFilterList = async () => {
  await getScoreStageFilter().then((res) => {
    allData.value = res.data;
    // 省份 只需要code和name
    provinceValList2.value = allData.value.map(
      ({ provinceCode, provinceName }) => ({
        provinceCode,
        provinceName,
      })
    );

    provinceVal2.value =
      Number(localStorage.getItem('provinceId')) ||
      allData.value[0].provinceCode;
    professionList.value = allData.value[0].configs[0].courses;
    profession.value = professionList.value[0].course;

    provinceVal2Name.value = allData.value.filter(
      (v) => v.provinceCode == provinceVal2.value
    )[0].provinceName;
    let resultProData = allData.value.filter(
      (v) => v.provinceCode == provinceVal2.value
    );
    yearList.value = resultProData[0].configs.map((v) => v.year);
    year.value = yearList.value[0];

    const provinceData = res.data.filter(
      (v) => v.provinceCode == provinceVal2.value
    );
    const yearData = provinceData[0].configs.filter(
      (v) => v.year == year.value
    );
    let optionsList = [];
    console.log(yearData[0].courses, '专业1');

    optionsList = yearData[0].courses.flatMap((course) => course.bzTypes);
    levelOptionsList.value = [...new Set(optionsList)];
    console.log(levelOptionsList.value, '专业');

    levelVal.value = levelOptionsList.value[0];

    // 有统一的省份
    if (
      Number(localStorage.getItem('provinceId')) &&
      allData.value.some(
        (obj) => obj.provinceCode == Number(localStorage.getItem('provinceId'))
      )
    ) {
      provinceVal2.value = Number(localStorage.getItem('provinceId'));
      for (const v of allData.value) {
        if (v.provinceCode == provinceVal2.value) {
          for (const vv of v.configs) {
            if (vv.year == year.value) {
              professionList.value = vv.courses;
              profession.value = professionList.value[0].course;
            }
          }
        }
      }
    }

    // 从智能填报跳转
    if (
      Number(JSON.parse(localStorage.getItem('zntbProvinceId'))) &&
      allData.value.some(
        (obj) =>
          obj.provinceCode ==
          Number(JSON.parse(localStorage.getItem('zntbProvinceId')))
      )
    ) {
      provinceVal2.value = Number(
        JSON.parse(localStorage.getItem('zntbProvinceId'))
      );
      for (const v of allData.value) {
        if (v.provinceCode == provinceVal2.value) {
          for (const vv of v.configs) {
            if (vv.year == year.value) {
              professionList.value = vv.courses;
              profession.value = professionList.value[0].course;
            }
          }
        }
      }
    }
    if (!!Number(JSON.parse(localStorage.getItem('zntbScore')))) {
      score.value = Number(JSON.parse(localStorage.getItem('zntbScore')));
      TFscore.value = Number(JSON.parse(localStorage.getItem('zntbScore')));
    }

    // 同分去向
    if (activeName.value == 'third') {
      selectedIndex.value = 0; // 默认选中第一个
      searchTFlists();
    } else if (activeName.value == 'four') {
      // 选科查询的年份省份与其他不同需要单独获取
      getSelectProvinceInfo();
      setTimeout(() => {
        fetchSearchSchool();
      }, 1000);
    } else {
      getScoreStageInfoList();
    }
  });
};

// 选科查询-获取省份和年份
const getSelectProvinceInfo = async () => {
  await getSelectProvince({ eduLevel: eduLevelValue.value }).then((res) => {
    provinceVal3.value =
      localStorage.getItem('provinceId') || res.data[0].provinceCode;
    provinceValList3.value = res.data;

    yearList2.value =
      provinceValList3.value.filter(
        (i) => i.provinceCode == provinceVal3.value
      )[0]?.years || provinceValList3.value[0]?.years;
    year2.value = yearList2.value[0]?.year;
  });
};

// 选科查询-修改批次
const xkEduLevelChange = (val) => {
  eduLevelValue.value = val;
  getSelectProvinceInfo();
  setTimeout(() => {
    fetchSearchSchool();
  }, 1000);
};

// 改变年份
function yearChange(val) {
  year.value = val;
  professionList.value = [];
  const provinceData = allData.value.filter(
    (v) => v.provinceCode == provinceVal2.value
  );
  let yearData = provinceData[0].configs.filter((v) => v.year == year.value);

  professionList.value = yearData[0].courses;
  profession.value = professionList.value[0].course;

  handleInitLevelData(provinceVal2.value);
  getScoreStageInfoList();
}

// 改变省份
function provinceChange2(val, type) {
  if (type == '一分一段') {
    console.log('一分一段');
    getScoreStageFilterList();
  }
  if (type == '同分去向') {
    console.log('同分去向');
    getScoreStageFilterList();
  }
  localStorage.setItem('provinceId', val);
  provinceVal1.value = val;
  provinceVal2.value = val;

  for (const v of allData.value) {
    if (v.provinceCode == val) {
      yearList.value = v.configs.map((v) => {
        return v.year;
      });
      year.value = yearList.value[0];
      professionList.value = v.configs[0].courses;
      profession.value = professionList.value[0].course;

      provinceValList2.value.filter((v) => {
        if (v.provinceCode == val) {
          provinceVal2Name.value = v.provinceName;
        }
      });
    }
  }
  if (activeName.value == 'second') {
    handleInitLevelData(val);
    getScoreStageInfoList();
  } else if (activeName.value == 'third') {
    selectedIndex.value = 0;
    searchTFlists(TFscore.value, 'search');
  }
}
const handleInitLevelData = (province) => {
  const provinceData = allData.value.filter((v) => v.provinceCode == province);
  let yearData = provinceData[0].configs.filter((v) => v.year == year.value);
  levelOptionsList.value = [];
  levelOptionsList.value = yearData[0].courses.flatMap(
    (course) => course.bzTypes
  );
  levelOptionsList.value = [...new Set(levelOptionsList.value)];
  levelVal.value = levelOptionsList.value[0];
};

function subjectChange(val) {
  profession.value = val;
  if (activeName.value == 'second') {
    getScoreStageInfoList();
  } else if (activeName.value == 'third') {
    searchTFlists();
  }
}
const levelChange = (val) => {
  levelVal.value = val;
  if (activeName.value == 'second') {
    getScoreStageInfoList();
  } else if (activeName.value == 'third') {
    searchTFlists();
  }
};

// 搜索框
function getSchoolScorelineList(val) {
  score.value = val;
  getScoreStageInfoList();
}

// 查询信息
function getScoreStageInfoList() {
  loading2.value = true;
  const data = {
    bzType: levelVal.value,
    course: profession.value,
    pid: provinceVal2.value,
    score: score.value ? score.value : '',
    year: year.value,
  };
  console.log('进来这里');

  if (!!data.score) {
    getScoreStageInfo2(data).then((res) => {
      highestRank.value = res.data.now_section.highestRank;
      lowestRank.value = res.data.now_section.lowestRank;
      sameCount.value = res.data.now_section.sameCount;

      tableData.value = res.data.list;
      yearscore.value = res.data.yearscore;
    });
    getScoreStageInfo1(data).then((res) => {
      scoreTableData.value = res.data;
      // 同分去向的加减分取值，首次加载取第一个最低值
      TFminscore.value = Number(scoreTableData.value[0]?.eqScore);
      TFmaxscore.value = Number(TFminscore.value + 4);
    });
  } else {
    ElMessage.warning({
      message: '请输入分数',
      type: 'warning',
    });
  }

  loading2.value = false;
}

// 查询更多-诊断成绩省份
async function getSearchFilter() {
  try {
    const res = await searchFilter();
    // 诊断成绩省份
    diagnosisData.value = res.data;
    diagnosisProvernceSelecData.value = res.data[0].name;
    // 诊断成绩城市
    diagnosisCityData.value = res.data[0].children;
    diagnosisCitySelectData.value = diagnosisCityData.value[0].name;
    // 诊断成绩文理
    diagnosisTypeWl.value = res.data[0].course;
    diagnosisTypeWlSelectData.value = diagnosisTypeWl.value[0];
    // 诊断成绩类型
    diagnosisType.value = diagnosisCityData.value[0].children.filter(
      (item) => item.course == diagnosisTypeWlSelectData.value
    );
    diagnosisTypeSelectData.value = diagnosisType.value[0].datakey;
  } catch (err) {
    console.log('err:', err);
  }
}

// 诊断成绩省份-修改省份
function diagnosisDataChangeProvernce(val) {
  // 诊断成绩城市
  diagnosisCityData.value = diagnosisData.value.filter(
    (item) => item.name == val
  )[0].children;
  diagnosisCitySelectData.value = diagnosisCityData.value[0].name;

  // 诊断成绩文理
  diagnosisTypeWl.value = diagnosisData.value.filter(
    (item) => item.name == val
  )[0].course;
  diagnosisTypeWlSelectData.value = diagnosisTypeWl.value[0];

  // 诊断成绩类型
  diagnosisType.value = diagnosisCityData.value[0].children.filter(
    (item) => item.course == diagnosisTypeWlSelectData.value
  );
  diagnosisTypeSelectData.value = diagnosisType.value[0].name;
  searchDataKey.value = diagnosisType.value[0].datakey;
}
// 诊断成绩省份-修改地级市
function diagnosisDataChangeCity(val) {
  // 诊断成绩文理
  diagnosisTypeWl.value = diagnosisData.value.filter(
    (item) => item.name == diagnosisProvernceSelecData.value
  )[0].course;
  diagnosisTypeWlSelectData.value = diagnosisTypeWl.value[0];

  // 诊断成绩类型
  diagnosisType.value = diagnosisCityData.value
    .filter((item) => item.name == val)[0]
    .children.filter((i) => i.course == diagnosisTypeWlSelectData.value);
  diagnosisTypeSelectData.value = diagnosisType.value[0].name;
  searchDataKey.value = diagnosisType.value[0].datakey;
}
// 诊断成绩省份-修改文理
function diagnosisDataChangeWl(val) {
  // 诊断成绩类型
  diagnosisType.value = diagnosisCityData.value
    .filter((item) => item.name == diagnosisCitySelectData.value)[0]
    .children.filter((i) => i.course == val);
  diagnosisTypeSelectData.value = diagnosisType.value[0].name;
  searchDataKey.value = diagnosisType.value[0].datakey;
}
// 诊断成绩省份-修改类型
function diagnosisDataChangeType(val) {
  searchDataKey.value = val;
}

// 查询成绩
function getTransScore() {
  const data = {
    datakey: searchDataKey.value || diagnosisTypeSelectData.value,
    score: diagnosisScore.value,
    course: diagnosisTypeWlSelectData.value,
  };
  if (!data.score) {
    ElMessage.error('请输入诊断考试成绩');
    return;
  }
  transScore(data)
    .then((res) => {
      transDataScore.value = res.data.score;
      transDataScoreRank.value = res.data.rank;
      tt.value = res.data.tt;
    })
    .catch((err) => {
      console.log('err:', err);
      transDataScore.value = '';
      transDataScoreRank.value = '';
    });
}

function setActiveName(val) {
  activeName.value = val || 'first';
  handleClick();
}

defineExpose({
  setActiveName,
});

onMounted(() => {
  getSearchFilter();
});
</script>

<style lang="scss" scoped>
.major-table {
  height: 100% !important;
}
:deep(.el-tabs__header) {
  position: sticky;
  // top: -20px;
  top: 0;
  z-index: 2;
  background-color: white;
}

table {
  tr {
    background-color: #fff;

    th,
    td {
      height: 60px;
      text-align: center;
      border: 1px solid #ebeef5;
    }
  }
}
#ToolCollegeLibraryList {
  margin-top: 20px;
}
.isActive {
  color: #409eff;
}
.table1,
.table2 {
  margin-top: 80px;
}

.tabstag-table {
  margin-top: 0;
}

:deep(.el-table__cell) {
  text-align: center;
  /* 设置表格内容居中 */
}

.title {
  text-align: left;
  font-weight: bold;
  margin: 20px 0;
  font-size: 16px;
}

.select-box {
  display: flex;
  flex-direction: row;
  padding: 20px 0;
  // position: fixed;
  top: 120px;
  z-index: 100;
  background-color: #fff;
}

.content {
  margin-top: 40px;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  .title {
    font-size: 20px;
  }
  .table {
    margin-top: 40px;
    display: flex;
    flex-direction: row;
    .score {
      display: inline-block;
      font-size: 20px;
      .num {
        font-size: 30px;
        color: #00b5d2;
      }
    }
    .score:last-child {
      margin-left: 40px;
    }
  }
}

.pcl-title {
  text-align: center;
  font-weight: bold;
  margin: 70px 0 20px;
  font-size: 16px;
}

.pcl-title {
  text-align: center;
  font-weight: bold;
  margin: 20px 0;
  font-size: 16px;
}

table {
  width: 100%;
  border-collapse: collapse; //合并为一个单一的边框
  border-color: #dfe6ec; //边框颜色按实际自定义即可
  border-left: 1px solid #ebeef5;
}

thead tr th {
  background-color: #f8f8f9; //设置表格标题背景色
  padding: 6px;
  text-align: center;
}

tbody tr td {
  padding: 6px;
  height: 48px; //设置单元格最小高度
  border-right: 1px solid #ebeef5;
  border-bottom: 1px solid #ebeef5;
}

.pcl-table {
  background: #f5f5f5;
  height: 49px;
}

.search,
.section {
  margin: 0 20px;
}

.uzy-tzy-tip-instruction {
  font-size: 12px;
  color: #ff7d00;
  margin: 30px 0;
  line-height: 20px;
  width: 100%;
  border-radius: 3px;
  background: #fff7e8;
  padding: 10px;

  .el-row {
    display: flex;
    flex-direction: row;
    align-items: center;

    .el-icon {
      font-size: 20px;
      color: #ff7d00;
      margin-right: 20px;
    }

    .titleBox {
      font-size: 14px;
      font-weight: 400;
      color: #ff7d00;
      line-height: 22px;

      h6 {
        line-height: 20px;
        font-size: 14px;
        margin-bottom: 4px;
      }
    }
  }
}

// 同分去向
.scoreBox {
  height: 40px;
  background-color: #f7f8fa;
  padding: 6px 16px;
  line-height: 28px;
  font-size: 14px;
  border-radius: 4px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;

  .pointer {
    width: 110px;
    margin: 0 10px;
    background-color: #fff;
    padding: 0 10px;
    border-radius: 4px;
    border: 1px solid #fff;

    .text-info {
      color: #86909c;
    }
  }

  .isChecked {
    border: 1px solid #165dff;
    color: #165dff;
  }
}

.tabstag {
  // margin-top: 70px;
  position: relative;

  :deep(.el-tabs__header) {
    width: 30%;
    border-bottom: none;
    z-index: 1 !important;

    .el-tabs__nav {
      border-bottom: 1px solid #e4e7ed;
    }
  }
}

.table-search {
  // position: fixed;
  z-index: 3;
  // height: 120px;
  // background-color: #ffffff;
  // margin-top: -140px;
  top: 200px;

  .top {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    .left {
      border-radius: 5px;
      display: flex;
      flex-direction: row;
      border: 1px solid #e4e7ed;

      .left-item {
        width: 70px;
        height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        border-right: 1px solid #e4e7ed;
      }

      .active {
        color: #165dff;
      }

      .left-item:last-child {
        border-right: none;
      }
    }

    .tabstag-score {
      // position: absolute;
      // width: 25%;
      right: 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .button {
        border-color: #e5e6eb;
        background-color: #fff;
        color: #000;
        height: 30px;
        width: 60px;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 5px;
        border: 1px solid #e5e6eb;
      }

      .button:hover {
        background-color: #e8efff;
        color: #000;
        cursor: pointer;
      }

      .txt {
        background-color: #f7f8fa;
        border-radius: 5px;
        padding: 10px 20px;
        text-align: center;
        color: #4e5969;
        display: flex;
        align-items: center;
        height: 30px;
      }
    }
  }

  .down {
    margin: 20px 0 0 0;

    .table-header {
      font-size: 14px;
      padding: 15px 0;
      background-color: #f7f7f8;

      .plan-major-title {
        .plan-major-title-item {
          text-align: center;
          width: 20%;
          padding: 0 12px;
        }
      }
    }
  }
}

.table-content {
  // margin-top: 130px;

  .remarks {
    font-size: 12px;
    color: #bcc3cc;
  }
}
</style>
